home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / NextAnswers / 1395_Text_object_margins.rtf < prev    next >
Text File  |  1993-11-08  |  2KB  |  48 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;\f2\fmodern Ohlfs;}
  2. \paperw11620
  3. \paperh10240
  4. \margl120
  5. \margr120
  6. {\colortbl;\red0\green0\blue0;\red84\green84\blue84;\red83\green83\blue83;\red82\green82\blue82;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ulnone\fs28\fc0\cf0 Q:  How do the Text object margins work?\
  8.  
  9. \i     \
  10.  
  11. \i0 A: 
  12. \fc1\cf1  The margins do work, but it's difficult to correctly set them. You need to offset the values by the frame rectangle of the text.  The following code snippet illustrates the necessary steps:\
  13. \
  14.  
  15. \f1\fs24 /* This routine assumes that you have defined currentDocText somewhere else */ \
  16. \
  17. #define    DESIREDleftMARGIN    some int value\
  18. #define    DESIREDrightMARGIN    some int value\
  19. #define    DESIREDtopMARGIN    some int value\
  20. #define    DESIREDbottomMARGIN    some int value\
  21. \
  22.  
  23. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\fc1\cf1 - setMargins:sender\
  24. \{\
  25.     NXRect    aRect;\
  26.     \
  27.     /* Get the current frame values */\
  28.     [currentDocText getFrame:&aRect];\
  29.     [currentDocText setMarginLeft: NX_X(&aRect) + DESIREDleftMARGIN\
  30.             right: - NX_X(&aRect) + DESIREDrightMARGIN\
  31.             top: NX_Y(&aRect) + DESIREDtopMARGIN\
  32.             bottom: - NX_Y(&aRect) + DESIREDbottomMARGIN]; ];\
  33.     return self;\
  34. \}\
  35.  
  36. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28\fc1\cf1 \
  37. If you call 
  38. \f1\fs24 getMarginLeft:right:top:bottom:
  39. \f0\fs28 , the returned values are the same as the ones you provide to 
  40. \f1\fs24 setMarginLeft:right:top:bottom:
  41. \f0\fs28 .  So, to determine the "true" margins, you need to subtract the frame's dimensions.\
  42. \
  43. QA647\
  44. \
  45. Valid for 1.0, 2.0, 3.0\
  46. \
  47.  
  48.